home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2067 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  40 lines

  1. Newsgroups: comp.lang.c
  2. Path: news3.noc.netcom.net!zdc!zippo!usenet
  3. From: Jim McFarland <jgm6@orkand.em.cdc.gov>
  4. Subject: Re: DOS commands
  5. Content-Type: text/plain; charset=us-ascii
  6. Sender: usenet@news.zippo.com
  7. Content-Transfer-Encoding: 7bit
  8. Nntp-Posting-Host: 158.111.166.77
  9. Organization: The Orkand Corporation
  10. Message-ID: <DLDppy.Mt6@news.zippo.com>
  11. References: <30F6BED1.5E25@oak.westol.com>
  12. X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
  13. Mime-Version: 1.0
  14. Date: Thu, 18 Jan 1996 13:34:46 GMT
  15.  
  16. Mark Kintigh <breetai@oak.westol.com> wrote:
  17. >wayneft@indirect.com wrote:
  18. >> 
  19. >> I know that this is probably a stupid question, but it's been a while
  20. >> since I have programmed in C.  My question is what is the command in a
  21. >> C program that executes a DOS command such as DIR, or COPY.  I've
  22. >> looked through all my books and for some reason I just can't seem to
  23. >> find it.  I know it is a real simple command that is in the dos.h
  24. >> header file.  If someone could email me or post the command I would be
  25. >> very grateful, I need it because I have to something for work.
  26. >
  27. >There are two ways:
  28. >    exec()
  29. >    system()
  30. >Choose the one that suits you best!
  31.  
  32. No, exec() won't work with "dir".  Exec() functions only work with 
  33. executables or batch files.  The "dir" command does not have a 
  34. corresponding.com or .exe.  You must call system() to use "dir".  To find 
  35. out if you can use exec() to run a DOS command, make sure the command has 
  36. a .com or .exe file in \dos.
  37.  
  38. Jim
  39.  
  40.